﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace NowFloats.RichSnippetExtractor.MicroData
{
    public class MicroDataItem
    {
        public List<MicroDataItem> Items;
        public List<MicroDataProperty> Properties;
        public String Type { get; set; }

        public MicroDataItem()
        {

        }

        public MicroDataItem(String type)
        {
            this.Type = type;
        }

        public MicroDataItem(List<MicroDataItem> items, List<MicroDataProperty> properties, String type)
        {
            Items = items;
            Properties = properties;
            Type = type;
        }

        public void AddProperty(String property, String value = null)
        {
            if (Properties == null)
                Properties = new List<MicroDataProperty>();
            this.Properties.Add(new MicroDataProperty(property, value));
        }

        public void AddProperty(MicroDataProperty property)
        {
            if (Properties == null)
                Properties = new List<MicroDataProperty>();
            this.Properties.Add(property);
        }

        public void RemoveProperty(MicroDataProperty property)
        {
            if (Properties != null)
                if (Properties.Contains(property))
                    Properties.Remove(property);
        }

        public void AddItem(MicroDataItem item)
        {
            if (Items == null)
                Items = new List<MicroDataItem>();
            Items.Add(item);
        }

        public void RemoveItem(MicroDataItem item)
        {
            if (Items != null)
                if (Items.Contains(item))
                    Items.Remove(item);
        }
    }
}
